<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>  
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>用户列表</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

<jsp:include page="/WEB-INF/views/include/newhead.jsp" />

</head>
<body>
	<sys:message content="${message}"/>
	<form:form id="searchForm" modelAttribute="user" action="${ctx}/sys/user/dialogUserList" method="post" class="form-search ">
		<input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
		<input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
		<input type="hidden" name="officeId" value="${param.officeId}"/>
		<input type="hidden" name="doDataFilter" value="${param.doDataFilter}"/>
		<sys:tableSort id="orderBy" name="orderBy" value="${page.orderBy}" callback="page();"/>
		<div class="search-bar" style="margin-bottom: 10px;">
			<ul class="clearfix">
				<li>
					<span>登陆名：</span>
					<input type="text" name="loginName" class="form-control">
				</li>
				<li>
					<span>姓名：</span>
					<input type="text" name="name" class="form-control">
				</li>
			</ul>
			<div id="btn_search" class="search-btn" style="line-height: 80px;">查询</div>
			<script type="text/javascript">
				$(function(){
					$(".search-bar ul li").each(function(){
						var spanWidth = $(this).find("span").width();
						$(this).find(".form-control").width(230-20-spanWidth);	
						$(this).children(".input-append").find(".required").width(230-20-36+1-spanWidth);	
					});
				})
			</script>
		</div>
	</form:form>
	<div class="css-tl">
	<table id="contentTable" class="table table-striped table-bordered table-condensed jqgrid-select" style="margin-bottom: 0;">
		<thead><tr>
		<th style="width:20px;"><input type="checkbox" class="checkall"/></th>
		<th>登录名</th>
		<th>姓名</th>
		<th>归属部门</th>
		<th>归属公司</th>
		</tr></thead>
		<tbody>
		<c:if test="${empty page.list}">
			<tr class="undata">
				<td class="center" colspan=5>没有数据</td>
			</tr>
		</c:if>
		<c:forEach items="${page.list}" var="user">
			<tr>
				<td>
					<input type="checkbox"/>
					<input type="hidden" name="id" value="${user.id}"/>
					<input type="hidden" name="no" value="${user.no}"/>
					<input type="hidden" name="name" value="${user.name}"/>
				</td>
				<td>${user.loginName}</td>
				<td>${user.name}</td>
				<td>${user.office.name}</td>
				<td>${user.company.name}</td>
			</tr>
		</c:forEach>
		</tbody>
	</table>
	<div class="pagination">${page}</div>
	
	<jsp:include page="/WEB-INF/views/include/pageJs.jsp" />
	
	<script>
		//isType=false的时候是
		var isType="false";
		var selects=false; //false 单选   true 可以多选
		isiFrame="${param.isiFrame}";
		
		if(selects){
			$(".checkall").removeAttr("disabled");
		}else{
			$(".checkall").attr("disabled","disabled");
		}
		
		$(".jqgrid-select tbody>tr").click(function(){
			$(".checkall").removeAttr("checked");
			if(selects){
				if($(this).hasClass("jdselect")){
					$(this).removeClass("jdselect");
					$(this).find("td:first input[type=checkbox]").prop("checked",false);
				}else{
					$(this).addClass("jdselect");
					$(this).find("td:first input[type=checkbox]").prop("checked",true);
				}
			}else{
				$(this).addClass("jdselect");
				$(this).find("td:first input[type=checkbox]").prop("checked",true);
				$(this).siblings().removeClass("jdselect");
				$(this).siblings().find("td:first input[type=checkbox]").prop("checked",false);
			}
			
			//新增标签
			addlabe($(this));
		});
		
		
		//全选
		$(".checkall").click(function(){
			if($(this).is(":checked")){
				$(this).parents("table").find("tr:gt(0)").addClass("jdselect");
				$(this).parents("table").find("tr:gt(0)").find("td:first input[type=checkbox]").attr("checked","true");
				
				allselecttr();
			}else{
				$(this).parents("table").find("tr:gt(0)").removeClass("jdselect");
				$(this).parents("table").find("tr:gt(0)").find("td:first input[type=checkbox]").removeAttr("checked");
				
				allselecttr()
			}
		});
		
		//全选tr且生成小标签
		function allselecttr(){
			$("#content",parent.document).find(".jszcselect>span").remove();
			var selecttrs=$(".jqgrid-select").find("tbody>tr");
			$.each(selecttrs,function(count,event){
				addlabe($(event));
			});
		}
		
		//强制去掉列表列表contents页滚动条
		$(function(){
			$(document).find("html").removeAttr("style");
			$(document).find("html").css({"overflow":"hidden"});
		});
		
		//生成标签
		function addlabe(event){
			var parentiFrame=$("#content",parent.document).find(".jszcselect");
			var id=event.find("td:first input[name=id]").val();
			var no=event.find("td:first input[name=no]").val();
			var name=event.find("td:first input[name=name]").val();
			
			if(!event.hasClass("jdselect")){
				parentiFrame.find("#s_"+id).remove();
			}else{
				var html="<span id='s_"+id+"'>"+name+"<input type='hidden' name='name' value='"+name+"'/><input type='hidden' name='no' value='"+no+"'><input type='hidden' name='id' value='"+id+"'></span>";
				parentiFrame.empty().append(html);
			}
		}
		
		function page(n, s) {
			$("#pageNo").val(n);
			$("#pageSize").val(s);
			$("#searchForm").submit();
			return false;
		}
		
	</script>
</body>
</html>